Skip to content

perf: make circle_map_realign more parallelized, try mem_mb dependent on thread number #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

dlaehnemann
Copy link
Member

@dlaehnemann dlaehnemann commented Jun 11, 2025

Summary by CodeRabbit

  • Chores
    • Updated resource allocation and threading configuration for improved performance during realignment steps.

Copy link

coderabbitai bot commented Jun 11, 2025

Walkthrough

The circle_map_realign rule in the workflow was updated to increase the number of threads from 4 to 16 and to modify the memory allocation logic. Memory is now calculated based on the number of threads rather than input file size. The shell command remains unchanged except for the updated thread count.

Changes

File(s) Change Summary
workflow/rules/circle_map.smk Increased threads from 4 to 16 in circle_map_realign rule; memory allocation now based on threads

Sequence Diagram(s)

sequenceDiagram
    participant Snakemake
    participant CircleMapRealign

    Snakemake->>CircleMapRealign: Run with threads=16, mem_mb=threads*5000
    CircleMapRealign-->>Snakemake: Processed output
Loading

Poem

Sixteen threads now hop along,
Memory grows, robust and strong.
Circles realign with greater might,
Bunnies cheer through day and night.
With every tweak, the workflow gleams,
Hopping forward, chasing dreams! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f9eaafb and 9253a84.

📒 Files selected for processing (1)
  • workflow/rules/circle_map.smk (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Formatting
  • GitHub Check: Linting
🔇 Additional comments (1)
workflow/rules/circle_map.smk (1)

44-46:

❓ Verification inconclusive

Ensure the resource lambda’s signature & memory scaling are cluster-compatible

  1. Snakemake forwards several positional arguments to resource lambdas (wildcards, input, threads, resources, attempt).
    • On versions < 7.17, the second positional argument is input, not threads_. • If your production environment is pinned to an older Snakemake, this will raise TypeError: () got multiple values for argument 'threads'`.

    A safer definition is:

-    resources:
-        mem_mb=lambda wc, threads: threads * 5000,
+    resources:
+        mem_mb=lambda wc, threads, **kwargs: threads * 5000,
  1. threads * 5000 → 80 GB for 16 threads. Confirm your cluster profile advertises mem_mb and that nodes with ≥80 000 MB are available; otherwise jobs will stay in the queue indefinitely.

  2. The previous formula scaled with input.size_mb; switching to a fixed 5 GB / thread may over-allocate for small samples and under-allocate for large ones. Consider keeping a hybrid or configurable factor (e.g. via config["circle_map_mem_per_thread"]).


🏁 Script executed:

#!/bin/bash
# Display the first 200 lines of the rule to inspect existing memory‐scaling logic
sed -n '1,200p' workflow/rules/circle_map.smk

Length of output: 2873


Validate resource lambda signature & memory scaling

Please review the following before merging:

  • If your Snakemake version is < 7.17, resource lambdas receive (wildcards, input, threads, resources, attempt), so the existing
    lambda wildcards, threads: … will raise a TypeError. To support both old and new Snakemake, add a catch-all **kwargs.
  • Verify your cluster profile advertises mem_mb and can schedule ≥ 80 000 MB for a 16-thread job, or the job may queue indefinitely.
  • Using a fixed 5 GB/thread may over- or under-allocate; consider a hybrid formula or a config-driven factor (e.g. config["circle_map_mem_per_thread"]).

Location:

  • workflow/rules/circle_map.smk → rule circle_map_realign

Suggested diff:

 rule circle_map_realign:
     …
     threads: 16
     resources:
-        mem_mb=lambda wildcards, threads: threads * 5000,
+        mem_mb=lambda wildcards, threads, **kwargs: threads * 5000,
     shell:
         "Circle-Map Realign …"

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@dlaehnemann dlaehnemann merged commit 545be19 into main Jun 11, 2025
7 checks passed
@dlaehnemann dlaehnemann deleted the perf/improve-circle-map-realigner-resource-requests branch June 11, 2025 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant